<template>
	<view class="pageview">
		<cl-navbar :title="$t('chum.index.title')" placeholder :autoBack="false" leftIcon=""></cl-navbar>
		<view class="pageContent">
			<view class="cellviewGrop" v-for="(group, groupIndex) in listData" :key="groupIndex">
				<view v-for="(item, itemIndex) in group.discover_list" :key="itemIndex" class="cellview" @click="gopage(item.url)">
					<view class="cellview__left">
						<cl-avatar :src="item.icon" size="70rpx" shape="square"></cl-avatar>
						<text class="cellview__left__title">{{ item.title }}</text>
					</view>
					<u-icon name="arrow-right" color="#ffffff"></u-icon>
				</view>
			</view>
		</view>
		<cl-tabbar :currentTab="2"></cl-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listData:[],
			}
		},
		onLoad() {
			uni.hideTabBar()
			this.getList()
		},
		methods: {
			async getList(){
				try{
					let resdata = await uni.$api.common.discoverList()
					if(resdata.code == 200){
						this.listData = resdata.data
						console.log(this.listData);
					}
				}catch(e){
					//TODO handle the exception
				}
			},
			gopageLocal(name){
				this.$Router.push({
					name
				})
			},
			gopage(url) {
				// const subNVue = uni.getSubNVueById('imageVideoSub') 
				// subNVue.show('fade-in',200,()=>{
				// 	console.log('subNVue 原生子窗体显示成功');
				// })
				// return
				if(!url)return
				//预加载
				plus.webview.prefetchURL(url);
				this.$Router.push({
					name:'chum_website',
					params: {
						url,
					},
					animation:{
						animationType:'slide-in-bottom'
					}
				})
			},
			
		}
	};
</script>

<style scoped lang="scss">
	.cellviewGrop {
		background: #1E1F30;
		border-radius: 20rpx;
		margin: 20rpx 30rpx 0;

		.cellview {
			display: flex;
			justify-content: space-between;
			padding: 20rpx;

			&__left {
				display: flex;
				align-items: center;

				&__img {
					width: 70rpx;
					height: 70rpx;
					border-radius: 20rpx;
				}

				&__title {
					font-size: 28rpx;
					margin-left: 20rpx;
					color: #FFFFFF;
				}
			}
		}
	}
</style>